package com.amos.base.util;

import com.amos.base.base.BaseDTO;
import com.amos.base.base.BaseEntity;

/**
 * 类操作Util
 * @author zhuqb
 */
public class ClassUtils {
    /**
     * 根据类创建对应的实例
     * @param cls
     * @param <T>
     * @return
     */
    public static <T extends BaseEntity> T newEntityInstance(Class<T> cls){
        T t = null;
        try{
            t = cls.newInstance();
        }catch (Exception e){
            e.printStackTrace();
        }
        return t;
    }
    /**
     * 根据DTO创建对应的实例
     * @param cls
     * @param <E>
     * @return
     */
    public static <E extends BaseDTO> E newDtoInstance(Class<E> cls){
        E t = null;
        try{
            t = cls.newInstance();
        }catch (Exception e){
            e.printStackTrace();
        }
        return t;
    }
}
